Pendulum Motion

Author: Neil Tramsen

Group Members: Anisa Hofert, Duncan Guy, Christina Jordan

In this project, we analyse the motion of a pendulum subject to dampening as well as a periodic driving force. The motion will be formulated as a differential equation, and solved using a number of integrating different algorithms, allowing us to determine their accuracy. We will then analyse which parameters lead to predictable oscillations, and which lead to chaotic motion.

Problem Analysis

Physical Considerations

A pendulum swings back and forth due to a restoring torque that acts perpendicular to the string. This restoring torque is provided by the component of gravity that is perpendicular to the position of the pendulum from the point about which it is rotating. In addition to the restoring torque, a resistive torque proportional to the angular velocity and a driving force also act on the pendulum. The pendulum will be modelled as a mass on the end of a massless, solid rod, allowing the pendulum to move anywhere on the perimeter of a circle.

The motion of a swinging pendulum is goverened by a number of parameters. The undriven pendulum's motion can be defined as a second order differential equation, depending on the length of the pendulum, the downward acceleration due to gravity, g, and a coefficient of drag. Exerting a periodic driving force on a pendulum will drastically alter its motion, with its motion now also dependent on the frequency of the driving force, the amplitude of the driving force, as well as the mass on the end of the pendulum, on which the driving force is acting.

We will limit the initial angular displacement to be between 0 and $\pi$, where 0 is the equilibrium point when the pendulum hangs straight down. The length and mass of the pendulum must both be greater than 0. The frequency of the driving force must also be greater than or equal to 0.

Coding Considerations

This model is a time-dependent model, as tracks angular positions and velocities as they develop over time, and it is deterministic as the solution is only dependent on the intial conditions, such as the length, the characteristics of the driving force, and drag-coefficient. This means that identical initial conditions will produce identical outputs. The variables are continiuous, as both angular position and velocity will move through a continuous range of values over time. To initialize the problem we will need to specify the length of the pendulum, the mass of the pendulum, the coefficient of drag, the driving forces amplitude, and the driving forces angular frequency, $\omega_D$. The acceleration due to gravity is $9.81 ms^{-1}$.

We will solve the differential equation using 3 different numerical integrating algorithms. The first is the Euler method, which has an error associated with it that is proportional to the time steps, $\delta t$. The second is the Runge-Kutta Method, which has an associated error of $\delta t^2$. The third is the Scipi odeint library, which uses a faster and more andvanced algorithm to calculate the most accurate result. We will compare the algorithms and the errors they produce.

Model Development

The rotational analog to Newton's second law is

$$T = I^2\alpha.$$

There are three torques acting on the pendulum, a drag force which is proportional to the angular speed, the component of gravity perpendicular to the string, and the driving force.

$$I^2\alpha = -mgl\sin{(\theta)}-bl\omega+A\cos{(\omega_Dt)}$$

The rotational inertia of a pendulum is $I = ml^2$. Furthermore, $\omega$ and $\alpha$ are the first and second derivatives of the angle of displacement, $\theta$.

$$ml^2\ddot{\theta}+bl\dot{\theta}+mgl\sin{(\theta)}=A\cos{(\omega_Dt)}$$$$\ddot{\theta}+\frac{b}{ml}\dot{\theta}+\frac{g}{l}\sin{(\theta)}=\frac{A}{ml^2}\cos{(\omega_Dt)}$$

This complicated differential equation of multiple variables can be converted to a system of 3 first order differential equations.

$$\begin{cases} \frac{d\omega}{dt}=-\alpha\omega-\beta\sin{(\theta)}+\gamma\cos{(\phi)}\\\frac{d\theta}{dt}=\omega\\\frac{d\phi}{dt}=\omega_D \end{cases}$$

This is the set of differential equations that our pendulum function will represent, where $\alpha$, $\beta$, and $\gamma$ are constants to be calculated based on the parameters that the user inputs.

Model Implementation

Initialising Python

Checking Parameters and calculating constants based on parameters

Pendulum Function

Integrators

Comparing Algorithm run times and errors

Run time comparison

Error Analysis

As predicted, the RK2 Method has a smaller absolute error when integrating over a time period. It also makes sense that the RK2 error has a steeper gradient, as error is proportional to $dt^2$, whereas Euler's error is proportional to $dt$. Also, the smaller, $dt$, is the more accurate the result, as making the smaller steps in time decreases the relative error for each step.

Comparing Phase Portraits

We will analyse the phase portraits of a pendulum with a small initial angular displacement, and no driving force. This will become important for our model verification later on.

Constant Initialisation

Undamped Pendulum

When there is no damping at all, the solution will keep moving around in cycles, as there is nothing to hinder motion, hence the circular cycles in the ohase portrait.

Underdamped Pendulum

When underdamped, the solution will oscillate but eventually tend to 0, hence the limit cycle in the phase portrait.

Overdamped Pendulum

When overdamped, there is no oscillation, and all solutions tend to 0.

Critically Damped Pendulum

When critically damped, all the solutions will take the quickest path to 0. This occurrs when the drag factor is equal to the natural frequency of the pendulum.

The relationship between damping factor and omega

To determine which drag coefficient is most effective at daming this system, we will plot the absolute value of displacement after 2 seconds of motion against the value of the drag factor. The samller the displacement, the more effective the damping.

The above graph shows that critical damping for this system ocurrs at around b=5.4, as this is where the pendulum has minimum displacement after 2 seconds. The minimum at 3.3 is not due to critical to damping, but due to the fact, that an integer number of oscillations occurrs after 2 seconds, so the amplitude is 0 anyway.

Comparing run time and accuracy of integrators

Chaotic Motion

Chaotic motion is defined as unpredictable development of a system. In a pendulum, changing the initial parameters by a certain amount, $\Delta x$, causes a change in the subsequent motion on the order of $\Delta x$. The Pendulum is moving chaotically when the change in motion itself is constantly changing, and there is no resemblance to a $\Delta x$.

Model Verification

Test Cases

One way of verifying the model is testing it for some initial conditions for which the result is known. We will test some easily verifyable expected solutions, by changing the initial conditions to specific values.

Simple Harmonic Motion

One way to verufy the code is to see whether it agrees with the known results of simple harmonic motion. For a pendulum to move in simple harmonic motion, the driving force must be 0, and the maximum angle of displacement must be kept small, so that

$$\sin{(\theta)}\approx\theta.$$

This converts the differential equation into an ordinary differential equation that is easily solvable:

$$\ddot{\theta}+\frac{b}{ml}\dot{\theta}+\frac{g}{l}\theta=0$$$$\ddot{\theta}+2\beta\dot{\theta}+\omega^2\theta=0$$$$\theta = e^{-\beta}\left(c_1e^{\sqrt{\beta^2-\omega^2}t}+c_2e^{-\sqrt{\beta^2-\omega^2}t}\right)$$

If $\beta = 0$:$$\theta = A\cos{(\omega t)}+B\sin{(\omega t)}$$ This leads to continuous oscillatory motion of the particle, as expected when there is no drag.

If $\beta < \omega$:$$\theta = e^{-\beta t}\left[A\cos{(\omega t)}+B\sin{(\omega t)}\right]$$ This leads to oscillatory motion, but the oscillations will continually grow smaller until motion stops. This is underdamping.

If $\beta = \omega$: $$\theta = Ae^{-\beta t}$$ In this case the solution to the equation is just the negative exponential, which is the solution for critical damping.

If $\beta > \omega$:$$\theta = e^{-\beta}\left(c_1e^{x_1t}+c_2e^{x_2t}\right)$$ Both $x_1$ and $x_2$ are less than $\beta$, so the fucntion still decays to 0 as time goes on, but it will do so more slowly than in the critical damping case. This is overdamping.

Our function exhibits all these properties, as shown in the phase portraits in the phase portraits when there is no driving force, shown above. Furthermore, we defined $\omega$ as $\sqrt{\frac{g}{l}}$, which allows us to calculate the time period. If we run one of our integrators for exactly that time period, and start $\theta$ at its maximum, we should see $\theta$ return to its maximum at the end of the time period, and we should see exactly one period of motion.

As expected, the pendulum oscillates exactly once during its time period.

Discussion and Conclusion

The Euler, Runge-Kutta, and OdeInt methods all find plausible solutions for the angular position and velocity of a pendulum over time, with errors and processing times which have been thouroughly analyzed. The pendulum function was verified by approximating the pendulum's motion as simple harmonic motion, for which the algorithm outputted matching results. We explained the phase planes for the undriven pendulum, which also support the simple harmonic motion model, and have found cases for which the driven oscillator behaves chaotically. This program can be used to accurately model the development of a pendulum over time, something which is analytically very hard, and sometimes even impossible, to do.